/**
 * Created by zy on 2016/6/16.
 * 完整性评价 - 推送设置 - 系统设置 - 系统设置
 */

;(function ($, window, document, undefined) {

    /**
     * 获取设置数据 - start
     */
    var baseData = function () {
        var temp = '';
        DyyBase.ajax(sysApi.url_settings_threshold(), {type: 'INTEGRITY_ASSESSMENT'}, function (dataset) {
            temp = dataset.result;
        }, {async: false});
        return temp;
    }();
    /**
     * 获取设置数据 - end
     */

    //console.log(baseData);

    /**
     * 角色数据 - start
     */
    // 角色列表
    var role_list = function () {
        var temp = $.trim($('#JQ_data_role_list').html());
        temp = eval('(' + temp + ')');
        return temp;
    }();

    // 角色对应
    var role_map = function () {
        var temp = $.trim($('#JQ_data_role_map').html());
        temp = eval('(' + temp + ')');
        return temp;
    }();
    /**
     * 角色数据 - start
     */


    /**
     * 内检测周期控件初始化 - start
     */
    // 管道
    var $pipeline = $('#JQ_pipeline').select3({
        search: false,
        allowClear: false
    });
    // 管段
    var $segment = $('#JQ_segment').select3({
        title: '管段',
        search: false,
        allowClear: false
    });
    // 起点位置
    var $begin = $('#JQ_begin').select3({
        search: false,
        title: '起点位置',
        server: true,
        allowClear: false,
        param: {
            'pipeLineId': $pipeline,
            'pipeSegmentId': $segment
        }
    });
    // 终点位置
    var $end = $('#JQ_end').select3({
        search: false,
        title: '终点位置',
        server: true,
        allowClear: false,
        param: {
            'pipeLineId': $pipeline,
            'pipeSegmentId': $segment,
            'beginSignId': $begin
        }
    });
    // 触发管道
    $pipeline.element.on('select', function (e, v, t) {
        var id = v || $pipeline.val();
        if (id) {
            // 管段
            DyyBase.ajax(DyyBase.url_segment(), {pipeLineId: id}, function (dataset) {
                var json = DyyBase.getSelect(dataset);
                $segment.add(json);
            });
            // 起点 & 终点
            if (t === undefined) {
                DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId: id}, function (dataset) {
                    var begin = DyyBase.getPos(dataset, 'begin');
                    var end = DyyBase.getPos(dataset, 'end');
                    $begin.asset(begin);
                    $end.asset(end);
                });
            }
        } else {
            $segment.add([]);
            $begin.add([]);
            $end.add([]);
        }
    });
    // 触发管段
    $segment.element.on('select', function (e, v) {
        var id = v || $segment.val();
        if (id) {
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId: id}, function (dataset) {
                var begin = DyyBase.getPos(dataset, 'begin');
                var end = DyyBase.getPos(dataset, 'end');
                $begin.asset(begin);
                $end.asset(end);
            });
        } else {
            $begin.add([]);
            $end.add([]);
        }
    });
    // 风险评价间隔周期
    var $cycle = $('#JQ_cycle').select3({
        search: false,
        allowClear: false,
        data: [
            {id: '1', text: '一月'},
            {id: '2', text: '二月'},
            {id: '3', text: '三月'},
            {id: '4', text: '四月'},
            {id: '5', text: '五月'},
            {id: '6', text: '六月'},
            {id: '7', text: '七月'},
            {id: '8', text: '八月'},
            {id: '9', text: '九月'},
            {id: '10', text: '十月'},
            {id: '11', text: '十一月'},
            {id: '12', text: '十二月'}
        ]
    });
    // 提前通知评价天数
    var $advance = $('#JQ_advance');
    // 初次检测时间
    $.datetimepicker.setLocale('zh');
    var $date = $('#JQ_date');
    $date.datetimepicker({
        timepicker: false,
        format: 'Y-m',
        scrollInput: false,
        validateOnBlur: false
    });
    /**
     * 内检测周期控件初始化 - end
     */


    /**
     * 外检测周期控件初始化 - start
     */
    // 管道
    var $pipeline2 = $('#JQ_pipeline2').select3({
        data: $pipeline.val('store'),
        search: false,
        allowClear: false
    });
    // 管段
    var $segment2 = $('#JQ_segment2').select3({
        title: '管段',
        search: false,
        allowClear: false
    });
    // 起点位置
    var $begin2 = $('#JQ_begin2').select3({
        search: false,
        title: '起点位置',
        server: true,
        allowClear: false,
        param: {
            'pipeLineId': $pipeline2,
            'pipeSegmentId': $segment2
        }
    });
    // 终点位置
    var $end2 = $('#JQ_end2').select3({
        search: false,
        title: '终点位置',
        server: true,
        allowClear: false,
        param: {
            'pipeLineId': $pipeline2,
            'pipeSegmentId': $segment2,
            'beginSignId': $begin2
        }
    });
    // 触发管道
    $pipeline2.element.on('select', function (e, v) {
        var id = v || $pipeline2.val();
        if (id) {
            // 管段
            DyyBase.ajax(DyyBase.url_segment(), {pipeLineId: id}, function (dataset) {
                var json = DyyBase.getSelect(dataset);
                $segment2.add(json);
            });
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId: id}, function (dataset) {
                var begin = DyyBase.getPos(dataset, 'begin');
                var end = DyyBase.getPos(dataset, 'end');
                $begin2.asset(begin);
                $end2.asset(end);
            });
        } else {
            $segment2.add([]);
            $begin2.add([]);
            $end2.add([]);
        }
    });
    // 触发管段
    $segment2.element.on('select', function (e, v) {
        var id = v || $segment2.val();
        if (id) {
            // 起点 & 终点
            DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId: id}, function (dataset) {
                var begin = DyyBase.getPos(dataset, 'begin');
                var end = DyyBase.getPos(dataset, 'end');
                $begin2.asset(begin);
                $end2.asset(end);
            });
        } else {
            $begin2.add([]);
            $end2.add([]);
        }
    });
    // 风险评价间隔周期
    var $cycle2 = $('#JQ_cycle2').select3({
        search: false,
        allowClear: false,
        data: [
            {id: '1', text: '一月'},
            {id: '2', text: '二月'},
            {id: '3', text: '三月'},
            {id: '4', text: '四月'},
            {id: '5', text: '五月'},
            {id: '6', text: '六月'},
            {id: '7', text: '七月'},
            {id: '8', text: '八月'},
            {id: '9', text: '九月'},
            {id: '10', text: '十月'},
            {id: '11', text: '十一月'},
            {id: '12', text: '十二月'}
        ]
    });
    // 提前通知评价天数
    var $advance2 = $('#JQ_advance2');
    // 初次检测时间
    var $date2 = $('#JQ_date2');
    $date2.datetimepicker({
        timepicker: false,
        format: 'Y-m',
        scrollInput: false,
        validateOnBlur: false
    });
    /**
     * 外检测周期控件初始化 - end
     */


    /**
     * 插件化页面复选下拉框 - start
     */
    var $list_box_01;
    var $list_box_02;
    var $list_box_03;
    var $list_box_04;
    var $list_box_05;
    var $list_box_06;
    var $list_box_07;
    var $list_box_08;
    var $list_box_09;
    var $list_box_10;
    var $list_box_11;
    var $list_box_12;
    var $list_box_13;
    var $list_box_14;
    /**
     * 插件化页面复选下拉框 - end
     */


    /** 内检 - start **/
    // 初始行
    var $org = $('#JQ_org_line');
    // 初始添加按钮
    var $create = $('#JQ_create_cycle');
    // 多行容器
    var $mulit = $('#JQ_mulit_line');
    // 内部金属损失
    var $inside_loss = $('#JQ_inside_loss');
    // 外部部金属损失
    var $outside_loss = $('#JQ_outside_loss');
    // 提醒天数
    var $notice = $('#JQ_notice');
    /** 内检 - end **/


    /** 外检 - start **/
    // 初始行
    var $org2 = $('#JQ_org_line2');
    // 初始添加按钮
    var $create2 = $('#JQ_create_cycle2');
    // 多行容器
    var $mulit2 = $('#JQ_mulit_line2');
    // 过保护
    var $too_protect = $('#JQ_too_protect');
    // 欠保护
    var $loss_protect = $('#JQ_loss_protect');
    // 损坏可用
    var $usable = $('#JQ_usable');
    // 损坏不可用
    var $disabled = $('#JQ_disabled');
    // 缺失
    var $buried = $('#JQ_buried');
    // 干扰强度 - ac
    var $ac_grade = $('#JQ_ac_grade').select3({
        data: [
            {id: 'BIG', text: '强'},
            {id: 'ORDINARY', text: '中'},
            {id: 'LITTLE', text: '弱'}
        ],
        search: false,
        allowClear: false
    });
    // 干扰强度 - dc
    var $dc_grade = $('#JQ_dc_grade').select3({
        data: [
            {id: 'BIG', text: '强'},
            {id: 'ORDINARY', text: '中'},
            {id: 'LITTLE', text: '弱'}
        ],
        search: false,
        allowClear: false
    });
    // 三级
    var $3_grade = $('#JQ_3_grade');
    // 四级
    var $4_grade = $('#JQ_4_grade');
    // 防腐层
    var $coat_advance = $('#JQ_coat_advance');
    /** 外检 - end **/


    /**
     * 添加行操作 - start
     */
        // 初始添加行按钮 - 1
    $create.click(function () {
        addLine();
    });

    // 初始添加行按钮 - 2
    $create2.click(function () {
        addLine2();
    });

    var select3_obj1 = [
        [],
        [],
        [],
        []
    ];

    var select3_obj2 = [
        [],
        [],
        [],
        []
    ];

    // 添加行操作 - 1
    function addLine(idx) {

        // 建立索引
        var t_idx = 0;
        if (idx != undefined) {
            t_idx = --idx;
        }

        var $copy = $org.find('figure').clone(true);

        // 管道
        var $pipe = $copy.find('blockquote.org-pipe').select3({
            index: t_idx,
            data: $pipeline.val('store'),
            search: false,
            allowClear: false
        });
        // 管段
        var $segment = $copy.find('blockquote.org-segment').select3({
            index: t_idx,
            title: '管段',
            search: false,
            allowClear: false
        });
        // 起点位置
        var $begin = $copy.find('blockquote.org-begin').select3({
            index: t_idx,
            title: '起点位置',
            server: true,
            search: false,
            allowClear: false,
            param: {
                'pipeLineId': $pipeline,
                'pipeSegmentId': $segment
            }
        });
        // 终点位置
        var $end = $copy.find('blockquote.org-end').select3({
            index: t_idx,
            title: '终点位置',
            server: true,
            search: false,
            allowClear: false,
            param: {
                'pipeLineId': $pipeline,
                'pipeSegmentId': $segment,
                'beginSignId': $begin
            }
        });
        // 触发管道
        $pipe.element.on('select', function (e, v) {
            var id = v || $pipe.val();
            if (id) {
                // 管段
                DyyBase.ajax(DyyBase.url_segment(), {pipeLineId: id}, function (dataset) {
                    var json = DyyBase.getSelect(dataset);
                    $segment.add(json);
                });
                // 起点 & 终点
                DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId: id}, function (dataset) {
                    var begin = DyyBase.getPos(dataset, 'begin');
                    var end = DyyBase.getPos(dataset, 'end');
                    $begin.asset(begin);
                    $end.asset(end);
                });
            } else {
                $segment.add([]);
                $begin.add([]);
                $end.add([]);
            }
        });
        // 触发管段
        $segment.element.on('select', function (e, v) {
            var id = v || $segment.val();
            if (id) {
                // 起点 & 终点
                DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId: id}, function (dataset) {
                    var begin = DyyBase.getPos(dataset, 'begin');
                    var end = DyyBase.getPos(dataset, 'end');
                    $begin.asset(begin);
                    $end.asset(end);
                });
            } else {
                $begin.add([]);
                $end.add([]);
            }
        });

        // 周期
        var $cycle = $copy.find('blockquote.org-cycle').select3({
            search: false,
            allowClear: false,
            data: [
                {id: '1', text: '一月'},
                {id: '2', text: '二月'},
                {id: '3', text: '三月'},
                {id: '4', text: '四月'},
                {id: '5', text: '五月'},
                {id: '6', text: '六月'},
                {id: '7', text: '七月'},
                {id: '8', text: '八月'},
                {id: '9', text: '九月'},
                {id: '10', text: '十月'},
                {id: '11', text: '十一月'},
                {id: '12', text: '十二月'}
            ]
        });
        // 角色
        var $role = $copy.find('div.org-check').DropCheckbox({
            list: role_list
        });
        // 初次评价时间
        var $advance = $copy.find('input.zy-i-input-date-0');
        $advance.datetimepicker({
            timepicker: false,
            format: 'Y-m',
            scrollInput: false,
            validateOnBlur: false
        });

        // 删除按钮
        var $deletebtn = $copy.find('button.zy-delete-s');
        $deletebtn.off('click').click(function () {
            $(this).parent('div').parent('div').parent('figure').remove();
        });
        // 添加按钮
        var $addbtn = $copy.find('button.zy-create-s');
        $addbtn.off('click').click(function () {
            addLine();
        });

        // 追加整行
        $mulit.append($copy);
    }

    // 添加行操作 - 2
    function addLine2(idx) {

        // 建立索引
        var t_idx = 0;
        if (idx != undefined) {
            t_idx = --idx;
        }

        var $copy = $org2.find('figure').clone(true);

        // 管道
        var $pipe = $copy.find('blockquote.org-pipe2').select3({
            index: t_idx,
            data: $pipeline.val('store'),
            search: false,
            allowClear: false
        });
        // 管段
        var $segment = $copy.find('blockquote.org-segment2').select3({
            index: t_idx,
            title: '管段',
            search: false,
            allowClear: false
        });
        // 起点位置
        var $begin = $copy.find('blockquote.org-begin2').select3({
            index: t_idx,
            title: '起点位置',
            server: true,
            search: false,
            allowClear: false,
            param: {
                'pipeLineId': $pipeline,
                'pipeSegmentId': $segment
            }
        });
        // 终点位置
        var $end = $copy.find('blockquote.org-end2').select3({
            index: t_idx,
            title: '终点位置',
            server: true,
            search: false,
            allowClear: false,
            param: {
                'pipeLineId': $pipeline,
                'pipeSegmentId': $segment,
                'beginSignId': $begin
            }
        });
        // 触发管道
        $pipe.element.on('select', function (e, v) {
            var id = v || $pipe.val();
            if (id) {
                // 管段
                DyyBase.ajax(DyyBase.url_segment(), {pipeLineId: id}, function (dataset) {
                    var json = DyyBase.getSelect(dataset);
                    $segment.add(json);
                });
                // 起点 & 终点
                DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId: id}, function (dataset) {
                    var begin = DyyBase.getPos(dataset, 'begin');
                    var end = DyyBase.getPos(dataset, 'end');
                    $begin.asset(begin);
                    $end.asset(end);
                });
            } else {
                $segment.add([]);
                $begin.add([]);
                $end.add([]);
            }
        });
        // 触发管段
        $segment.element.on('select', function (e, v) {
            var id = v || $segment.val();
            if (id) {
                // 起点 & 终点
                DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId: id}, function (dataset) {
                    var begin = DyyBase.getPos(dataset, 'begin');
                    var end = DyyBase.getPos(dataset, 'end');
                    $begin.asset(begin);
                    $end.asset(end);
                });
            } else {
                $begin.add([]);
                $end.add([]);
            }
        });

        // 周期
        var $cycle = $copy.find('blockquote.org-cycle2').select3({
            search: false,
            allowClear: false,
            data: [
                {id: '1', text: '一月'},
                {id: '2', text: '二月'},
                {id: '3', text: '三月'},
                {id: '4', text: '四月'},
                {id: '5', text: '五月'},
                {id: '6', text: '六月'},
                {id: '7', text: '七月'},
                {id: '8', text: '八月'},
                {id: '9', text: '九月'},
                {id: '10', text: '十月'},
                {id: '11', text: '十一月'},
                {id: '12', text: '十二月'}
            ]
        });
        // 角色
        var $role = $copy.find('div.org-check2').DropCheckbox({
            list: role_list
        });
        // 初次评价时间
        var $advance = $copy.find('input.zy-i-input-date-0');
        $advance.datetimepicker({
            timepicker: false,
            format: 'Y-m',
            scrollInput: false,
            validateOnBlur: false
        });

        // 删除按钮
        var $deletebtn = $copy.find('button.zy-delete-s');
        $deletebtn.off('click').click(function () {
            $(this).parent('div').parent('div').parent('figure').remove();
        });
        // 添加按钮
        var $addbtn = $copy.find('button.zy-create-s');
        $addbtn.off('click').click(function () {
            addLine2();
        });

        // 追加整行
        $mulit2.append($copy);
    }

    /**
     * 添加行操作 - end
     */


    /**
     *  初始化页面数据 - start
     */
    function initPage() {
        // 内检测 - 管道
        var pipe = baseData.INTERNAL_INSP_PIPE_SCHEDULE.thresholdContentJson;
        var lenth = pipe.length;
        if (lenth > 0) {
            $pipeline.fit(pipe[0].pipeLineId);
            $pipeline.element.trigger('select', [$pipeline.val(), 'edit']);
            $begin.asset([{id: pipe[0].beginMileageId, text: pipe[0].beginName, mile: pipe[0].beginMileage}]);
            $end.asset([{id: pipe[0].endMileageId, text: pipe[0].endName, mile: pipe[0].endMileage}]);
            $date.val(pipe[0].firstTime);
            $cycle.fit(pipe[0].cycle);
            $advance.val(pipe[0].advance);
            $list_box_01 = $('#JQ_checkbox_list_01').DropCheckbox({
                list: role_list,
                data: pipe[0].roleId,
                roleMap: role_map
            });

            if (lenth > 1) {
                for (var i = 1; i < lenth; i++) {
                    // 新增行
                    addLine(i);
                    var $figure = $mulit.find('figure').eq(i - 1);
                    if ($figure.length) {
                        var $pipe_c = $figure.find('blockquote.org-pipe').select3({
                            allowClear: false,
                            search: false
                        }).fit(pipe[i].pipeLineId);
                        select3_obj1[0].push($pipe_c);

                        var $segment_c = $figure.find('blockquote.org-segment').select3({
                            allowClear: false,
                            search: false
                        });
                        select3_obj1[1].push($segment_c);

                        var $begin_c = $figure.find('blockquote.org-begin').select3({
                            allowClear: false,
                            search: false
                        }).asset([{
                            id: pipe[i].beginMileageId,
                            text: pipe[i].beginName,
                            mile: pipe[i].beginMileage
                        }]);
                        select3_obj1[2].push($begin_c);

                        var $end_c = $figure.find('blockquote.org-end').select3({
                            allowClear: false,
                            search: false
                        }).asset([{
                            id: pipe[i].endMileageId,
                            text: pipe[i].endName,
                            mile: pipe[i].endMileage
                        }]);
                        select3_obj1[3].push($end_c);

                        // 触发管道
                        select3_obj1[0][i - 1].element.on('select', function (e, v, idx) {
                            var id = v || select3_obj1[0][idx].val();
                            if (id) {
                                // 管段
                                DyyBase.ajax(DyyBase.url_segment(), {pipeLineId: id}, function (dataset) {
                                    var json = DyyBase.getSelect(dataset);
                                    select3_obj1[1][idx].add(json);
                                });
                                // 起点 & 终点
                                DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId: id}, function (dataset) {
                                    var begin = DyyBase.getPos(dataset, 'begin');
                                    var end = DyyBase.getPos(dataset, 'end');
                                    select3_obj1[2][idx].asset(begin);
                                    select3_obj1[3][idx].asset(end);
                                });
                            } else {
                                select3_obj1[1][idx].add([]);
                                select3_obj1[2][idx].add([]);
                                select3_obj1[3][idx].add([]);
                            }
                        });

                        // 触发管段
                        select3_obj1[1][i - 1].element.on('select', function (e, v, idx) {
                            var id = v || select3_obj1[1][idx].val();
                            if (id) {
                                // 起点 & 终点
                                DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId: id}, function (dataset) {
                                    var begin = DyyBase.getPos(dataset, 'begin');
                                    var end = DyyBase.getPos(dataset, 'end');
                                    select3_obj1[2][idx].asset(begin);
                                    select3_obj1[3][idx].asset(end);
                                });
                            } else {
                                select3_obj1[2][idx].add([]);
                                select3_obj1[3][idx].add([]);
                            }
                        });

                        $figure.find('input.zy-i-input-date-0').val(pipe[i].firstTime);

                        $figure.find('blockquote.org-cycle').select3({
                            allowClear: false,
                            search: false
                        }).fit(pipe[i].cycle);

                        $figure.find('input.org-advance').val(pipe[i].advance);

                        $figure.find('div.org-check').DropCheckbox({
                            data: pipe[i].roleId,
                            roleMap: role_map
                        });
                    }
                }
            }
        }
        /*---------------------------------------------------------------------------------*/

        // 外检测 - 管道
        var pipe2 = baseData.INTERNAL_EXTE_PIPE_SCHEDULE.thresholdContentJson;
        var lenth2 = pipe2.length;
        if (lenth2 > 0) {
            $pipeline2.fit(pipe2[0].pipeLineId);
            $pipeline2.element.trigger('select');
            $begin2.asset([{id: pipe2[0].beginMileageId, text: pipe2[0].beginName, mile: pipe2[0].beginMileage}]);
            $end2.asset([{id: pipe2[0].endMileageId, text: pipe2[0].endName, mile: pipe2[0].endMileage}]);
            $date2.val(pipe2[0].firstTime);
            $cycle2.fit(pipe2[0].cycle);
            $advance2.val(pipe2[0].advance);
            $list_box_06 = $('#JQ_checkbox_list_06').DropCheckbox({
                list: role_list,
                data: pipe2[0].roleId,
                roleMap: role_map
            });

            if (lenth2 > 1) {
                for (var j = 1; j < lenth2; j++) {
                    // 新增行
                    addLine2(j);
                    var $figure2 = $mulit2.find('figure').eq(j - 1);
                    if ($figure2.length) {
                        var $pipe_c = $figure2.find('blockquote.org-pipe2').select3({
                            allowClear: false,
                            search: false
                        }).fit(pipe2[j].pipeLineId);
                        select3_obj2[0].push($pipe_c);

                        var $segment_c = $figure2.find('blockquote.org-segment2').select3({
                            allowClear: false,
                            search: false
                        });
                        select3_obj2[1].push($segment_c);

                        var $begin_c = $figure2.find('blockquote.org-begin2').select3({
                            allowClear: false,
                            search: false
                        }).asset([{
                            id: pipe2[j].beginMileageId,
                            text: pipe2[j].beginName,
                            mile: pipe2[j].beginMileage
                        }]);
                        select3_obj2[2].push($begin_c);

                        var $end_c = $figure2.find('blockquote.org-end2').select3({
                            allowClear: false,
                            search: false
                        }).asset([{
                            id: pipe2[j].endMileageId,
                            text: pipe2[j].endName,
                            mile: pipe2[j].endMileage
                        }]);
                        select3_obj2[3].push($end_c);

                        // 触发管道
                        select3_obj2[0][j - 1].element.on('select', function (e, v, idx) {
                            var id = v || select3_obj2[0][idx].val();
                            if (id) {
                                // 管段
                                DyyBase.ajax(DyyBase.url_segment(), {pipeLineId: id}, function (dataset) {
                                    var json = DyyBase.getSelect(dataset);
                                    select3_obj2[1][idx].add(json);
                                });
                                // 起点 & 终点
                                DyyBase.ajax(DyyBase.url_pipe_pos(), {pipeLineId: id}, function (dataset) {
                                    var begin = DyyBase.getPos(dataset, 'begin');
                                    var end = DyyBase.getPos(dataset, 'end');
                                    select3_obj2[2][idx].asset(begin);
                                    select3_obj2[3][idx].asset(end);
                                });
                            } else {
                                select3_obj2[1][idx].add([]);
                                select3_obj2[2][idx].add([]);
                                select3_obj2[3][idx].add([]);
                            }
                        });

                        // 触发管段
                        select3_obj2[1][j - 1].element.on('select', function (e, v, idx) {
                            var id = v || select3_obj2[1][idx].val();
                            if (id) {
                                // 起点 & 终点
                                DyyBase.ajax(DyyBase.url_segment_pos(), {pipeSegmentId: id}, function (dataset) {
                                    var begin = DyyBase.getPos(dataset, 'begin');
                                    var end = DyyBase.getPos(dataset, 'end');
                                    select3_obj2[2][idx].asset(begin);
                                    select3_obj2[3][idx].asset(end);
                                });
                            } else {
                                select3_obj2[2][idx].add([]);
                                select3_obj2[3][idx].add([]);
                            }
                        });

                        $figure2.find('input.zy-i-input-date-0').val(pipe2[j].firstTime);

                        $figure2.find('blockquote.org-cycle2').select3({
                            allowClear: false,
                            search: false
                        }).fit(pipe2[j].cycle);

                        $figure2.find('input.org-advance2').val(pipe2[j].advance);

                        $figure2.find('div.org-check2').DropCheckbox({
                            data: pipe2[j].roleId,
                            roleMap: role_map
                        });
                    }
                }
            }
        }
        /*---------------------------------------------------------------------------------*/

        $list_box_02 = $('#JQ_checkbox_list_02').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_INSP_APPRAISE.roleId,
            roleMap: role_map
        });
        /*---------------------------------------------------------------------------------*/

        // 提醒开展管体缺陷修复工作
        $list_box_03 = $('#JQ_checkbox_list_03').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_INSP_DEFECT_NOTICE_SCHEDULE.roleId,
            roleMap: role_map
        });
        $notice.val(baseData.INTERNAL_INSP_DEFECT_NOTICE_SCHEDULE.thresholdContentJson.day);
        /*---------------------------------------------------------------------------------*/

        // 内部金属损失
        $list_box_04 = $('#JQ_checkbox_list_04').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_INSP_INSIDE_METAL_LOSS.roleId,
            roleMap: role_map
        });
        $inside_loss.val(baseData.INTERNAL_INSP_INSIDE_METAL_LOSS.thresholdContentJson.percent);
        /*---------------------------------------------------------------------------------*/

        // 外部金属损失
        $list_box_05 = $('#JQ_checkbox_list_05').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_INSP_OUTSIDE_METAL_LOSS.roleId,
            roleMap: role_map
        });
        $outside_loss.val(baseData.INTERNAL_INSP_OUTSIDE_METAL_LOSS.thresholdContentJson.percent);
        /*---------------------------------------------------------------------------------*/

        // 阴极保护有效性
        $list_box_07 = $('#JQ_checkbox_list_07').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_CATHODIC_PROTECTION_INPUT.roleId,
            roleMap: role_map
        });
        if (baseData.INTERNAL_CATHODIC_PROTECTION_INPUT.thresholdContentJson.overProtection) {
            $too_protect.addClass('active');
        }
        if (baseData.INTERNAL_CATHODIC_PROTECTION_INPUT.thresholdContentJson.underProtection) {
            $loss_protect.addClass('active');
        }
        /*---------------------------------------------------------------------------------*/

        // 电位桩
        $list_box_08 = $('#JQ_checkbox_list_08').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_POTENTIAL_INPUT.roleId,
            roleMap: role_map
        });
        if (baseData.INTERNAL_POTENTIAL_INPUT.thresholdContentJson.damageAvail) {
            $usable.addClass('active');
        }
        if (baseData.INTERNAL_POTENTIAL_INPUT.thresholdContentJson.damageNotAvail) {
            $disabled.addClass('active');
        }
        if (baseData.INTERNAL_POTENTIAL_INPUT.thresholdContentJson.deficiency) {
            $buried.addClass('active');
        }
        /*---------------------------------------------------------------------------------*/

        // 交流电流密度
        $list_box_09 = $('#JQ_checkbox_list_09').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_AC_CURRENT_DENSITY_INPUT.roleId,
            roleMap: role_map
        });
        $ac_grade.fit(baseData.INTERNAL_AC_CURRENT_DENSITY_INPUT.thresholdContentJson.interference);
        /*---------------------------------------------------------------------------------*/

        // 直流电流密度
        $list_box_10 = $('#JQ_checkbox_list_10').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_DC_CURRENT_DENSITY_INPUT.roleId,
            roleMap: role_map
        });
        $dc_grade.fit(baseData.INTERNAL_DC_CURRENT_DENSITY_INPUT.thresholdContentJson.interference);
        /*---------------------------------------------------------------------------------*/

        // 绝缘接头
        $list_box_11 = $('#JQ_checkbox_list_11').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_INSULATION_JOINT_INPUT.roleId,
            roleMap: role_map
        });
        /*---------------------------------------------------------------------------------*/

        // 牺牲阳极
        $list_box_12 = $('#JQ_checkbox_list_12').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_SACRIFICIAL_ANODE_INPUT.roleId,
            roleMap: role_map
        });
        /*---------------------------------------------------------------------------------*/

        // 防腐层等级
        $list_box_13 = $('#JQ_checkbox_list_13').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_PROTECTING_COATING_INPUT.roleId,
            roleMap: role_map
        });
        if (baseData.INTERNAL_PROTECTING_COATING_INPUT.thresholdContentJson.three) {
            $3_grade.addClass('active');
        }
        if (baseData.INTERNAL_PROTECTING_COATING_INPUT.thresholdContentJson.four) {
            $4_grade.addClass('active');
        }
        /*---------------------------------------------------------------------------------*/

        // 防腐层漏损点
        $list_box_14 = $('#JQ_checkbox_list_14').DropCheckbox({
            list: role_list,
            data: baseData.INTERNAL_PROTECTING_COATING_ADVISE_INPUT.roleId,
            roleMap: role_map
        });
        $coat_advance.val(baseData.INTERNAL_PROTECTING_COATING_ADVISE_INPUT.thresholdContentJson.day);
        /*---------------------------------------------------------------------------------*/
    }

    initPage();
    /**
     *  初始化页面数据 - end
     */


    /**
     * 注入数据 - start
     */
    function pushData() {
        // 管道周期设置 - 内检测
        baseData.INTERNAL_INSP_PIPE_SCHEDULE.thresholdContentJson = [];

        var pipe = {};
        pipe.advance = $advance.val();
        pipe.cycle = $cycle.val();
        pipe.firstTime = $date.val();
        pipe.pipeLineId = $pipeline.val();
        pipe.pipeLineName = $pipeline.val('text');
        pipe.beginMileageId = $begin.val();
        pipe.beginName = $begin.val('text');
        pipe.endMileageId = $end.val();
        pipe.endName = $end.val('text');
        pipe.roleId = $list_box_01.spans.join(',');
        pipe.order = 1;
        baseData.INTERNAL_INSP_PIPE_SCHEDULE.thresholdContentJson.push(pipe);

        var $figures = $mulit.find('figure'), order = 1;
        if ($figures.length > 0) {
            $figures.each(function (i) {
                var $this = $(this);
                var pipes = {};
                pipes.advance = $this.find('input.org-advance').val();
                pipes.cycle = $this.find('blockquote.org-cycle').data('value');
                pipes.firstTime = $this.find('input.zy-i-input-date-0').val();
                pipes.pipeLineId = $this.find('blockquote.org-pipe').data('value');
                pipes.pipeLineName = $this.find('blockquote.org-pipe').data('text');
                pipes.beginMileageId = $this.find('blockquote.org-begin').data('value');
                pipes.beginName = $this.find('blockquote.org-begin').data('text');
                pipes.endMileageId = $this.find('blockquote.org-end').data('value');
                pipes.endName = $this.find('blockquote.org-end').data('text');
                pipes.roleId = $this.find('div.org-check').data('store');
                pipes.order = ++i + order;
                if (pipes.pipeLineId) {
                    baseData.INTERNAL_INSP_PIPE_SCHEDULE.thresholdContentJson.push(pipes);
                }
            });
        }


        // 管道周期设置 - 外检测
        baseData.INTERNAL_EXTE_PIPE_SCHEDULE.thresholdContentJson = [];

        var pipe2 = {};
        pipe2.advance = $advance2.val();
        pipe2.cycle = $cycle2.val();
        pipe2.firstTime = $date2.val();
        pipe2.pipeLineId = $pipeline2.val();
        pipe2.pipeLineName = $pipeline2.val('text');
        pipe2.beginMileageId = $begin2.val();
        pipe2.beginName = $begin2.val('text');
        pipe2.endMileageId = $end2.val();
        pipe2.endName = $end2.val('text');
        pipe2.roleId = $list_box_06.spans.join(',');
        pipe2.order = 1;
        baseData.INTERNAL_EXTE_PIPE_SCHEDULE.thresholdContentJson.push(pipe2);

        var $figures2 = $mulit2.find('figure'), order2 = 1;
        if ($figures2.length > 0) {
            $figures2.each(function (i) {
                var $this = $(this);
                var pipes = {};
                pipes.advance = $this.find('input.org-advance2').val();
                pipes.cycle = $this.find('blockquote.org-cycle2').data('value');
                pipes.firstTime = $this.find('input.zy-i-input-date-0').val();
                pipes.pipeLineId = $this.find('blockquote.org-pipe2').data('value');
                pipes.pipeLineName = $this.find('blockquote.org-pipe2').data('text');
                pipes.beginMileageId = $this.find('blockquote.org-begin2').data('value');
                pipes.beginName = $this.find('blockquote.org-begin2').data('text');
                pipes.endMileageId = $this.find('blockquote.org-end2').data('value');
                pipes.endName = $this.find('blockquote.org-end2').data('text');
                pipes.roleId = $this.find('div.org-check2').data('store');
                pipes.order = ++i + order2;
                if (pipes.pipeLineId) {
                    baseData.INTERNAL_EXTE_PIPE_SCHEDULE.thresholdContentJson.push(pipes);
                }
            });
        }

        // 提醒开展内检测工作
        baseData.INTERNAL_INSP_APPRAISE.roleId = $list_box_02.spans.join(',');
        /*---------------------------------------------------------------------------------*/

        // 提醒开展管体缺陷修复工作
        baseData.INTERNAL_INSP_DEFECT_NOTICE_SCHEDULE.roleId = $list_box_03.spans.join(',');
        baseData.INTERNAL_INSP_DEFECT_NOTICE_SCHEDULE.thresholdContentJson.day = $notice.val();
        /*---------------------------------------------------------------------------------*/

        // 内部金属损失
        baseData.INTERNAL_INSP_INSIDE_METAL_LOSS.roleId = $list_box_04.spans.join(',');
        baseData.INTERNAL_INSP_INSIDE_METAL_LOSS.thresholdContentJson.percent = $inside_loss.val();
        /*---------------------------------------------------------------------------------*/

        // 外部金属损失
        baseData.INTERNAL_INSP_OUTSIDE_METAL_LOSS.roleId = $list_box_05.spans.join(',');
        baseData.INTERNAL_INSP_OUTSIDE_METAL_LOSS.thresholdContentJson.percent = $outside_loss.val();
        /*---------------------------------------------------------------------------------*/

        // 阴极保护有效性
        baseData.INTERNAL_CATHODIC_PROTECTION_INPUT.roleId = $list_box_07.spans.join(',');
        baseData.INTERNAL_CATHODIC_PROTECTION_INPUT.thresholdContentJson.overProtection = $too_protect.hasClass('active') ? 1 : '';
        baseData.INTERNAL_CATHODIC_PROTECTION_INPUT.thresholdContentJson.underProtection = $loss_protect.hasClass('active') ? 1 : '';
        /*---------------------------------------------------------------------------------*/

        // 电位桩
        baseData.INTERNAL_POTENTIAL_INPUT.roleId = $list_box_08.spans.join(',');
        baseData.INTERNAL_POTENTIAL_INPUT.thresholdContentJson.damageAvail = $usable.hasClass('active') ? 1 : '';
        baseData.INTERNAL_POTENTIAL_INPUT.thresholdContentJson.damageNotAvail = $disabled.hasClass('active') ? 1 : '';
        baseData.INTERNAL_POTENTIAL_INPUT.thresholdContentJson.deficiency = $buried.hasClass('active') ? 1 : '';
        /*---------------------------------------------------------------------------------*/

        // 交流电流密度
        baseData.INTERNAL_AC_CURRENT_DENSITY_INPUT.roleId = $list_box_09.spans.join(',');
        baseData.INTERNAL_AC_CURRENT_DENSITY_INPUT.thresholdContentJson.interference = $ac_grade.val();
        /*---------------------------------------------------------------------------------*/

        // 直流电流密度
        baseData.INTERNAL_DC_CURRENT_DENSITY_INPUT.roleId = $list_box_10.spans.join(',');
        baseData.INTERNAL_DC_CURRENT_DENSITY_INPUT.thresholdContentJson.interference = $dc_grade.val();
        /*---------------------------------------------------------------------------------*/

        // 绝缘接头
        baseData.INTERNAL_INSULATION_JOINT_INPUT.roleId = $list_box_11.spans.join(',');
        /*---------------------------------------------------------------------------------*/

        // 牺牲阳极
        baseData.INTERNAL_SACRIFICIAL_ANODE_INPUT.roleId = $list_box_12.spans.join(',');
        /*---------------------------------------------------------------------------------*/

        // 防腐层等级
        baseData.INTERNAL_PROTECTING_COATING_INPUT.roleId = $list_box_13.spans.join(',');
        baseData.INTERNAL_PROTECTING_COATING_INPUT.thresholdContentJson.three = $3_grade.hasClass('active') ? 1 : '';
        baseData.INTERNAL_PROTECTING_COATING_INPUT.thresholdContentJson.four = $4_grade.hasClass('active') ? 1 : '';
        /*---------------------------------------------------------------------------------*/

        // 防腐层漏损点
        baseData.INTERNAL_PROTECTING_COATING_ADVISE_INPUT.roleId = $list_box_14.spans.join(',');
        baseData.INTERNAL_PROTECTING_COATING_ADVISE_INPUT.thresholdContentJson.day = $coat_advance.val();
        /*---------------------------------------------------------------------------------*/

        return baseData;
    }

    /**
     * 注入数据 - end
     */

    /** 校验数据重复性有效性 - start **/
    function checkData() {

        var mode = true;

        // 多行 内检测 -> 管道 - 起点 - 终点
        var trunk_1 = [[], [], []];
        trunk_1[0].push($pipeline.val());
        trunk_1[1].push($begin.val());
        trunk_1[2].push($end.val());

        var $figures1 = $mulit.find('figure');
        if ($figures1.length > 0) {
            $figures1.each(function () {
                var $this = $(this);
                var $pipe = $this.find('blockquote.org-pipe');
                var $begin = $this.find('blockquote.org-begin');
                var $end = $this.find('blockquote.org-end');

                var v_pipe = $pipe.data('value');
                var v_begin = $begin.data('value');
                var v_end = $end.data('value');

                if (v_pipe) {
                    trunk_1[0].push(v_pipe);
                }
                if (v_begin) {
                    trunk_1[1].push(v_begin);
                }
                if (v_end) {
                    trunk_1[2].push(v_end);
                }
            });

            if (trunk_1[0].length !== trunk_1[1].length) {
                $(this).MSG({
                    type: 'error',
                    content: '管道起点位置不完整!'
                });
                return false;
            }
            if (trunk_1[0].length !== trunk_1[2].length) {
                $(this).MSG({
                    type: 'error',
                    content: '管道终点位置不完整!'
                });
                return false;
            }

            var temp_pipe_1 = trunk_1[0].join(',') + ',';
            var temp_begin_1 = trunk_1[1].join(',') + ',';
            var temp_end_1 = trunk_1[2].join(',') + ',';
            for (var i = 0, len = trunk_1[0].length; i < len; i++) {
                if (temp_pipe_1.replace((trunk_1[0][i] + ','), '').indexOf((trunk_1[0][i] + ',')) > -1) {
                    if(temp_begin_1.replace((trunk_1[1][i] + ','), '').indexOf((trunk_1[1][i] + ',')) > -1){
                        if(temp_end_1.replace((trunk_1[2][i] + ','), '').indexOf((trunk_1[2][i] + ',')) > -1){
                            ++i;
                            $(this).MSG({
                                type: 'error',
                                content: '内检测周期设置第' + i + '条管道存在重复设置!'
                            });
                            return false;
                        }
                    }
                }
            }

            // 时间 - 天数
            var $dates = $figures1.find('input.zy-i-input-date-0'), $days = $figures1.find('input.org-advance');
            if ($dates.length > 0) {
                $dates.each(function () {
                    var $this = $(this);
                    var v = $.trim($this.val());
                    if (v) {
                        var temp_v = v.split('-');
                        if (temp_v.length === 2) {
                            if (isNaN(temp_v[0]) || isNaN(temp_v[1])) {
                                $this.TIP({content: '初次内检测时间格式不正确!'});
                                mode = false;
                            } else {
                                if (temp_v[1] < 1 || temp_v[1] >= 13) {
                                    $this.TIP({content: '初次内检测时间格式不正确!'});
                                    mode = false;
                                }
                            }
                        } else {
                            $this.TIP({content: '初次内检测时间格式不正确!'});
                            mode = false;
                        }
                    } else {
                        $this.TIP({content: '初次内检测时间不能为空!'});
                        mode = false;
                    }
                });
            }
            if ($days.length > 0) {
                $days.each(function () {
                    var $this = $(this);
                    var v = $.trim($this.val());
                    if (v) {
                        if (!(/^[1-9]\d*$/g.test(v))) {
                            $this.TIP({content: '提前通知内检测天数须为正整数!'});
                            mode = false;
                        }
                    } else {
                        $this.TIP({content: '提前通知内检测天数不能为空!'});
                        mode = false;
                    }
                });
            }
        }

        // 单行 -> 时间 - 天数
        var date = $.trim($date.val()), day = $.trim($advance.val());
        if (date) {
            var temp_v = date.split('-');
            if (temp_v.length === 2) {
                if (isNaN(temp_v[0]) || isNaN(temp_v[1])) {
                    $date.TIP({content: '初次内检测时间格式不正确!'});
                    mode = false;
                } else {
                    if (temp_v[1] < 1 || temp_v[1] >= 13) {
                        $date.TIP({content: '初次内检测时间格式不正确!'});
                        mode = false;
                    }
                }
            } else {
                $date.TIP({content: '初次内检测时间格式不正确!'});
                mode = false;
            }
        } else {
            $date.TIP({content: '初次内检测时间不能为空!'});
            mode = false;
        }

        if (day) {
            if (!(/^[1-9]\d*$/g.test(day))) {
                $advance.TIP({content: '提前通知内检测天数须为正整数!'});
                mode = false;
            }
        } else {
            $advance.TIP({content: '提前通知内检测天数不能为空!'});
            mode = false;
        }

        // 管段阀值 - 1
        var percent_01 = $.trim($inside_loss.val());
        if (percent_01) {
            if (isNaN(percent_01)) {
                $inside_loss.TIP({content: '增长数量比例须为数字!'});
                mode = false;
            } else {
                if (percent_01 > 100 || percent_01 < 0) {
                    $inside_loss.TIP({content: '增长数量比例范围0~100!'});
                    mode = false;
                } else {
                    var temp_per = percent_01.split('.');
                    if (temp_per.length === 2) {
                        if (/^00/g.test(temp_per[0])) {
                            $inside_loss.TIP({content: '增长数量比例须为数字!'});
                            mode = false;
                        }
                    }
                }
            }
        } else {
            $inside_loss.TIP({content: '增长数量比例不能为空!'});
            mode = false;
        }

        // 管段阀值 - 2
        var percent_02 = $.trim($outside_loss.val());
        if (percent_02) {
            if (isNaN(percent_02)) {
                $outside_loss.TIP({content: '增长数量比例须为数字!'});
                mode = false;
            } else {
                if (percent_02 > 100 || percent_02 < 0) {
                    $outside_loss.TIP({content: '增长数量比例范围0~100!'});
                    mode = false;
                } else {
                    var temp_per2 = percent_02.split('.');
                    if (temp_per2.length === 2) {
                        if (/^00/g.test(temp_per2[0])) {
                            $outside_loss.TIP({content: '增长数量比例须为数字!'});
                            mode = false;
                        }
                    }
                }
            }
        } else {
            $outside_loss.TIP({content: '增长数量比例不能为空!'});
            mode = false;
        }

        // 通知天数
        var notice = $.trim($notice.val());
        if (notice) {
            if (!(/^[1-9]\d*$/g.test(notice))) {
                $notice.TIP({content: '通知天数须为正整数!'});
                mode = false;
            }
        } else {
            $notice.TIP({content: '通知天数不能为空!'});
            mode = false;
        }

        // 缺陷最迟维修时间提前通知天数
        var coat_advance = $.trim($coat_advance.val());
        if (coat_advance) {
            if (!(/^[1-9]\d*$/g.test(coat_advance))) {
                $coat_advance.TIP({content: '通知天数须为正整数!'});
                mode = false;
            }
        } else {
            $coat_advance.TIP({content: '通知天数不能为空!'});
            mode = false;
        }


        // 多行 外检测 -> 管道 - 起点 - 终点
        var trunk_2 = [[], [], []];
        trunk_2[0].push($pipeline2.val());
        trunk_2[1].push($begin2.val());
        trunk_2[2].push($end2.val());

        var $figures2 = $mulit2.find('figure');
        if ($figures2.length > 0) {
            $figures2.each(function () {
                var $this = $(this);
                var $pipe = $this.find('blockquote.org-pipe2');
                var $begin = $this.find('blockquote.org-begin2');
                var $end = $this.find('blockquote.org-end2');

                var v_pipe = $pipe.data('value');
                var v_begin = $begin.data('value');
                var v_end = $end.data('value');

                if (v_pipe) {
                    trunk_2[0].push(v_pipe);
                }
                if (v_begin) {
                    trunk_2[1].push(v_begin);
                }
                if (v_end) {
                    trunk_2[2].push(v_end);
                }
            });

            if (trunk_2[0].length !== trunk_2[1].length) {
                $(this).MSG({
                    type: 'error',
                    content: '管道起点位置不完整!'
                });
                return false;
            }
            if (trunk_2[0].length !== trunk_2[2].length) {
                $(this).MSG({
                    type: 'error',
                    content: '管道终点位置不完整!'
                });
                return false;
            }

            var temp_pipe_2 = trunk_2[0].join(',') + ',';
            var temp_begin_2 = trunk_2[1].join(',') + ',';
            var temp_end_2 = trunk_2[2].join(',') + ',';
            for (var j = 0, lens = trunk_2[0].length; j < lens; j++) {
                if (temp_pipe_2.replace((trunk_2[0][j] + ','), '').indexOf((trunk_2[0][j] + ',')) > -1) {
                    if(temp_begin_2.replace((trunk_2[1][j] + ','), '').indexOf((trunk_2[1][j] + ',')) > -1){
                        if(temp_end_2.replace((trunk_2[2][j] + ','), '').indexOf((trunk_2[2][j] + ',')) > -1){
                            ++j;
                            $(this).MSG({
                                type: 'error',
                                content: '外检测周期设置第' + j + '条管道存在重复设置!'
                            });
                            return false;
                        }
                    }
                }
            }

            // 时间 - 天数
            var $dates2 = $figures2.find('input.zy-i-input-date-0'), $days2 = $figures2.find('input.org-advance2');
            if ($dates2.length > 0) {
                $dates2.each(function () {
                    var $this = $(this);
                    var v = $.trim($this.val());
                    if (v) {
                        var temp_v = v.split('-');
                        if (temp_v.length === 2) {
                            if (isNaN(temp_v[0]) || isNaN(temp_v[1])) {
                                $this.TIP({content: '初次外检测时间格式不正确!'});
                                mode = false;
                            } else {
                                if (temp_v[1] < 1 || temp_v[1] >= 13) {
                                    $this.TIP({content: '初次外检测时间格式不正确!'});
                                    mode = false;
                                }
                            }
                        } else {
                            $this.TIP({content: '初次外检测时间格式不正确!'});
                            mode = false;
                        }
                    } else {
                        $this.TIP({content: '初次外检测时间不能为空!'});
                        mode = false;
                    }
                });
            }
            if ($days2.length > 0) {
                $days2.each(function () {
                    var $this = $(this);
                    var v = $.trim($this.val());
                    if (v) {
                        if (!(/^[1-9]\d*$/g.test(v))) {
                            $this.TIP({content: '提前通知外检测天数须为正整数!'});
                            mode = false;
                        }
                    } else {
                        $this.TIP({content: '提前通知外检测天数不能为空!'});
                        mode = false;
                    }
                });
            }
        }

        // 单行 -> 时间 - 天数
        var date2 = $.trim($date2.val()), day2 = $.trim($advance2.val());
        if (date2) {
            var temp_v2 = date.split('-');
            if (temp_v2.length === 2) {
                if (isNaN(temp_v2[0]) || isNaN(temp_v2[1])) {
                    $date2.TIP({content: '初次外检测时间格式不正确!'});
                    mode = false;
                } else {
                    if (temp_v2[1] < 1 || temp_v2[1] >= 13) {
                        $date2.TIP({content: '初次外检测时间格式不正确!'});
                        mode = false;
                    }
                }
            } else {
                $date2.TIP({content: '初次外检测时间格式不正确!'});
                mode = false;
            }
        } else {
            $date2.TIP({content: '初次外检测时间不能为空!'});
            mode = false;
        }

        if (day2) {
            if (!(/^[1-9]\d*$/g.test(day2))) {
                $advance2.TIP({content: '提前通知外检测天数须为正整数!'});
                mode = false;
            }
        } else {
            $advance2.TIP({content: '提前通知外检测天数不能为空!'});
            mode = false;
        }

        return mode;
    }

    /** 校验数据重复性有效性 - end **/

    // 保存更改设置
    $('#JQ_save_settings').click(function () {
        var bool = checkData();
        if (bool) {
            var $this = $(this);
            if ($this.attr('data-status') === 'true') {
                $this.attr('data-status', 'false');
                var data = JSON.stringify(pushData());
                DyyBase.ajax(sysApi.url_settings_inte_save(), data, function (dataset) {
                    $this.attr('data-status', 'true');
                    if (dataset.bool) {
                        $this.MSG({
                            type: 'success',
                            content: '完整性评价设置成功！'
                        });
                    } else {
                        $this.MSG({
                            type: 'error',
                            content: '完整性评价设置失败！'
                        });
                    }
                }, {headers: {"Content-Type": "application/json"}});
            }
        }
    });

    // 恢复默认设置
    $('#JQ_save_defaults').click(function () {
        if (checkData()) {
            var $this = $(this);
            if ($this.attr('data-status') === 'true') {
                $this.attr('data-status', 'false');
                DyyBase.ajax(sysApi.url_settings_inte_cancel(), {}, function (dataset) {
                    $this.attr('data-status', 'true');
                    if (dataset.bool) {
                        $(this).MSG({
                            type: 'success',
                            content: '完整性评价恢复默认设置成功！',
                            closeBtnExist: false,
                            yesBtnAct: DyyBase.pageReload
                        });
                    } else {
                        $(this).MSG({
                            type: 'error',
                            closeBtnExist: false,
                            content: '完整性评价恢复默认设置失败！'
                        });
                    }
                });
            }
        }
    });

})(jQuery, window, document);